package ro.bluecube.admlocal.users.impl;

import java.util.ArrayList;
import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import ro.bluecube.admlocal.users.UsersServiceLocal;
import ro.bluecube.admlocal.users.UsersServiceRemote;
import ro.bluecube.admlocal.users.entity.User;

/**
 * @author anton
 * Stateless session bean
 */
@Stateless
public class UsersServiceImpl implements UsersServiceRemote, UsersServiceLocal {
	
	@PersistenceContext
	EntityManager em;
	
	@SuppressWarnings("unchecked")
	public List<User> getAllUsers() {
		return new ArrayList<User>(em.createNamedQuery("findAllUsers").getResultList());
	}

	@Override
	public void addUser(User user) {
		em.persist(user);
	}
}
